#include "application.hpp"
#include <cstring>

namespace yep
{

vector<Application*> Application::applications;

static int bufferPos = 0;
static Application *applicationsBuffer[100];

Application::Application(const string& name_, const string& description_):
    name(name_),
    description(description_)
{
//    assert( _applications.count(name) == 0 );
    applications.push_back(this);
    applicationsBuffer[bufferPos++] = this;
}

Application::~Application()
{
}

vector<Application*> &Application::getApplications()
{
    if(applications.size() == 0)
    {
        for(int i = 0; i < bufferPos; ++i)
            applications.push_back(applicationsBuffer[i]);
        memset(applicationsBuffer, 0, bufferPos*sizeof(Application*));
    }
    return applications;
}

}
